package com.dsc.shoppcar.pojo;

/**
 * @author: Du Shun Chang
 * @title: Goods
 * @date: 2022/4/14 8:28
 * @description: TODO
 * @version：1.0
 */
public class Goods implements Comparable<Goods>  {
    private String id ;         // 商品编号
    private String name ;    // 商品名称
    private double price ;   // 单价
    private String img_url ; // 图片地址

    public Goods(String id, String name, double price, String img_url) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.img_url = img_url;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public double getPrice() {
        return price;
    }

    public String getImg_url() {
        return img_url;
    }

    @Override
    public String toString() {
        return "Goods [id=" + id + ", name=" + name + ", price=" + price + ", img_url=" + img_url + "]";
    }

    /**
     * 重写compareTo方法重新实现排序规则
     */
    @Override
    public int compareTo(Goods o) {
        int result = 0;
        result = this.id == o.id ? 1 : 0;
        return result;
    }
}
